//
//  ActionDetailControl.swift
//  Motion
//
//  Created by 悦月越悦 on 2021/3/24.
//

import SwiftUI

struct ActionDetailControl: View {
    @EnvironmentObject var detailViewModel: ActionDetailModel
    
    var body: some View {
        HStack{
            Button(action: {
                detailViewModel.getPreviousAction()
            }, label: {
                Image(systemName: "chevron.left")
                    .font(.system(size: 32, weight: .bold))
                    .foregroundColor(detailViewModel.curIdx == 0 ? Color.gray : Color.blue )
            })
            .disabled(detailViewModel.curIdx == 0)
            
            Button(action: {
                detailViewModel.getNextAction()
            }, label: {
                Image(systemName: "chevron.right")
                    .font(.system(size: 32, weight: .bold))
                    .foregroundColor(detailViewModel.curIdx == (detailViewModel.total - 1) ? Color.gray : Color.blue)
            })
            .disabled(detailViewModel.curIdx == (detailViewModel.total - 1))
        }
    }
}

struct ActionDetailControl_Previews: PreviewProvider {
    static var previews: some View {
        ActionDetailControl()
    }
}
